package DSCard;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.*;
public class dscard {

        // 1. 定义扑克牌结构
        enum Suit {SPADE, HEART, DIAMOND, CLUB} // 花色
        enum Rank { TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT,
            NINE, TEN, JACK, QUEEN, KING, ACE } // 点数

        static class Card {
            Suit suit;
            Rank rank;

            public Card(Suit suit, Rank rank) {
                this.suit = suit;
                this.rank = rank;
            }

            @Override
            public String toString() {
                return suit + "-" + rank;
            }
        }

        public static void main(String[] args) {
            // 2. 生成一副牌（52张）
            List<Card> deck = new ArrayList<>();
            for (Suit suit : Suit.values()) {
                for (Rank rank : Rank.values()) {
                    deck.add(new Card(suit, rank));
                }
            }

            // 3. 洗牌
            Collections.shuffle(deck);
            System.out.println("洗牌后的牌堆：" + deck);

            // 4. 创建三个玩家
            List<List<Card>> players = new ArrayList<>();
            for (int i = 0; i < 3; i++) {
                players.add(new ArrayList<>());
            }

            // 5. 发牌（每人5张）
            int playerIndex = 0;
            for (int i = 0; i < 15; i++) { // 3人*5张=15张
                players.get(playerIndex).add(deck.get(i));
                playerIndex = (playerIndex + 1) % 3;
            }

            // 6. 输出结果
            System.out.println("\n剩余牌数: " + (deck.size() - 15));
            for (int i = 0; i < players.size(); i++) {
                System.out.println("玩家" + (i+1) + "的牌：" + players.get(i));
            }
        }
}
